package com.tengju.bff.interfaces.manage.bonus;

import com.tengju.bff.interfaces.manage.bonus.facade.SubjectFacade;
import com.tengju.bff.interfaces.shared.AmountVO;
import com.tengju.bff.interfaces.shared.ApiResponse;
import com.tengju.bff.interfaces.shared.TableVO;
import com.tengju.bff.interfaces.shared.servlet.ManageEntrance;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenhang
 * @Date 2021/4/21
 */
@Validated
@RestController
@Api(tags = "服务费主体分配")
@RequestMapping(value = "manage/bonus/subject")
@Slf4j
@ManageEntrance
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class SubjectController {

    private final SubjectFacade subjectFacade;

    @RequiresRoles("sso")
    @ApiOperation(value = "服务费主体汇总", notes = "服务费主体汇总")
    @GetMapping(value = "statistics", produces = MediaType.APPLICATION_JSON_VALUE)
    public ApiResponse<TableVO> statistics(Integer month) {
        TableVO table = subjectFacade.statistics(month);
        return ApiResponse.newSuccess(table);
    }

    @RequiresRoles("sso")
    @ApiOperation(value = "服务费总计", notes = "服务费总计")
    @GetMapping(value = "summary", produces = MediaType.APPLICATION_JSON_VALUE)
    public ApiResponse<AmountVO> summary(Integer month) {
        AmountVO amountVO = subjectFacade.summary(month);
        return ApiResponse.newSuccess(amountVO);
    }

    @RequiresRoles("sso")
    @ApiOperation(value = "服务费主体sku明细", notes = "服务费主体sku明细")
    @GetMapping(value = "skuDetails", produces = MediaType.APPLICATION_JSON_VALUE)
    public ApiResponse<TableVO> skuDetails(Integer month,Integer pageIndex,Integer pageSize) {
        TableVO table = subjectFacade.skuDetails(month,pageIndex,pageSize);
        return ApiResponse.newSuccess(table);
    }
}
